package com.changgou.canal;
import com.alibaba.otter.canal.protocol.CanalEntry;
import com.xpand.starter.canal.annotation.*;
@CanalEventListener
public class CanalDataEventListener {

	/***
	 * 增加数据监听
	 * @param eventType
	 * @param rowData
	 */
	@InsertListenPoint
	public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
		rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
	}

	/***
	 * 修改数据监听
	 * @param rowData
	 */
	@UpdateListenPoint
	public void onEventUpdate(CanalEntry.RowData rowData) {
		System.out.println("UpdateListenPoint");
		rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
	}

	/***
	 * 删除数据监听
	 * @param eventType
	 */
	@DeleteListenPoint
	public void onEventDelete(CanalEntry.EventType eventType) {
		System.out.println("DeleteListenPoint");
	}

	/***
	 * 自定义数据修改监听
	 * @param eventType
	 * @param rowData
	 */
	@ListenPoint(destination = "example", schema = "changgou_content", table = {"tb_content_category", "tb_content"}, eventType = CanalEntry.EventType.UPDATE)
	public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
		System.err.println("DeleteListenPoint");
		rowData.getAfterColumnsList().forEach((c) -> System.out.println("By--Annotation: " + c.getName() + " ::   " + c.getValue()));
	}
}